import java.util.*;

/**
 * @author LKQ
 * @date 2022/6/5 14:58
 * @description 模拟，比赛的时候，如果给出了具体的模拟过程，那么按照步骤模拟就行
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] nums = {1, 3, 5, 2, 4, 8, 2, 2};
        solution.minMaxGame(nums);
    }

    public int minMaxGame(int[] nums) {
        while (true) {
            int n = nums.length;
            if (n == 1) {
                break;
            }
            int[] temp = new int[n / 2];
            for (int i = 0; i < n / 2; i += 2) {
                temp[i] = Math.min(nums[2 * i], nums[2 * i + 1]);
            }
            for (int i = 1; i < n / 2; i += 2) {
                temp[i] = Math.max(nums[2 * i], nums[2 * i + 1]);
            }
            nums = temp;
        }
        return nums[0];
    }
}
